package edu.xmut.yuepaibackend.controller;

import cn.hutool.core.util.StrUtil;
import edu.xmut.yuepaibackend.model.domain.SysTags;
import edu.xmut.yuepaibackend.service.SysTagsService;
import edu.xmut.yuepaibackend.utils.R;
import jakarta.annotation.Resource;
import lombok.Data;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/tags")
public class TagsController {

    @Resource
    private SysTagsService sysTagsService;

    @GetMapping("/search/{content}")
    public R searchAndAdd(@PathVariable("content") String content) {
        // 校验参数
        if (StrUtil.isBlank(content)) {
            return R.fail("不能为空");
        }
        List<SysTags> data = sysTagsService.searchAndAdd(content);
        return R.ok(data);
    }
}
